package com.station.search.controller;

import com.station.search.common.domain.WebResponse;
import com.station.search.common.domain.WebResponseBuilder;
import com.station.search.domain.dto.WxAuthCode2SessionDTO;
import com.station.search.domain.vo.WxLoginVO;
import com.station.search.util.WeixinHttpUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: JT
 * @date: 2021/10/19
 * @Title: 登录控制器
 */
@RestController
@RequestMapping("/login")
public class LoginController {

    @PostMapping("/wx")
    public WebResponse wxLogin(@RequestBody WxLoginVO wxLoginVO) {
        WxAuthCode2SessionDTO wxAuthCode2SessionDTO = WeixinHttpUtil.authCode2Session(wxLoginVO.getJsCode());
        return WebResponseBuilder.ok().data(wxAuthCode2SessionDTO);
    }

}
